<?php
declare (strict_types = 1);

namespace app\model;

use think\Model;
use think\model\concern\SoftDelete;

/**
 * @property bool $pay_type 支付方式:1=微信,2=支付宝
 * @property bool $status 状态:0=待付款,1=待发货,2=待收货,3=待评价,4=完成,5=取消
 * @property float $coupon_amount 优惠金额
 * @property float $freight 运费
 * @property float $goods_amount 商品价格
 * @property float $pay_amount 支付金额
 * @property float $total_amount 订单原价
 * @property int $address_id 地址
 * @property int $coupon_id 优惠券
 * @property int $deletetime
 * @property int $deliver_express_id 发货快递
 * @property int $goods_id 商品
 * @property int $id
 * @property int $num 数量
 * @property int $school_id 学校
 * @property int $spec_id 规格信息
 * @property int $user_id 用户
 * @property string $createtime 下单时间
 * @property string $deliver_expresswaybill 发货快递单号
 * @property string $delivertime 发货时间
 * @property string $mark 备注
 * @property string $order_no 订单编号
 * @property string $paytime 付款时间
 * @property string $size 尺码
 * @property-read \app\model\Address $address
 * @property-read \app\model\Goods $goods
 * @property-read \app\model\GoodsCoupon $coupon
 * @property-read \app\model\GoodsExpress $deliver_express
 * @property-read \app\model\GoodsSpec $spec
 * @property-read \app\model\School $school
 * @property-read \app\model\User $user
 * @method static \think\db\Query onlyTrashed()
 * @method static \think\db\Query withTrashed()
 * @mixin \think\Model
 */
class GoodsOrders extends Model
{
	use SoftDelete;
	protected $createTime = 'createtime';
	protected $deleteTime = 'deletetime';
	
	
	protected $type = [
		'paytime'=> 'timestamp',
		'delivertime'=> 'timestamp',
	];
	
	function goods()
	{
		return $this->belongsTo(Goods::class,'goods_id');
	}
	
	function spec()
	{
		return $this->belongsTo(GoodsSpec::class,'spec_id');
	}
	
	function address()
	{
		return $this->belongsTo(Address::class,'address_id');
	}
	
	function coupon()
	{
		return $this->belongsTo(GoodsCoupon::class,'coupon_id');
	}
	
	function deliverExpress()
	{
		return $this->belongsTo(GoodsExpress::class,'deliver_express_id');
	}
	
	function user()
	{
		return $this->belongsTo(User::class,'user_id');
	}
	
	function school()
	{
		return $this->belongsTo(School::class,'school_id');
	}
	
}
